package com.szrt.javaweb.teacher;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


/**
 * 	http://localhost:8080/mvn-springmvc-01-1609/teacher/list
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/teacher")
public class TeacherController {
	
	@RequestMapping("/list")
	public String xx(HttpServletRequest request){
		
		request.setAttribute("teacher", "13926583118");
		
		//   /pages/teacher/list.jsp
		return "teacher/list";
	}
	
	
	/**
	 * 如果只接收post请求。应该如何处理 method=RequestMethod.POST
	 * @param request
	 * @return
	 */
	/*@RequestMapping(value="/add",method=RequestMethod.POST)
	public String add(HttpServletRequest request,String teacherAge){
		
		System.out.println("进入add方法.....");
		String teacherName = request.getParameter("teacherName");
		//String teacherAge  = request.getParameter("teacherAge");
		
		System.out.println(teacherName);
		System.out.println(teacherAge);
		return "teacher/list";
	}*/
	
	
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/add?school=itjob&teacherAge=33
	@RequestMapping(value="/add",
			method=RequestMethod.GET,
			params="school=itjob",headers="laoshi=huanglaoshi")
	public String add2(String teacherAge){
		
		System.out.println("进入add itjob方法 laoshi=huanglaoshi....");
		System.out.println(teacherAge);
		return "teacher/list";
	}
	
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/add
	//?school=szrt&teacherAge=33
	@RequestMapping(value="/add",
			method=RequestMethod.GET,
			params="school=szrt")
	public String add3(String teacherAge){
		System.out.println("进入add szrt 中深软通方法....");
		System.out.println(teacherAge);
		return "teacher/list";
	}
	
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/add
	//?school=szrt&teacherAge=33
	/*@RequestMapping(value="/add",
			method=RequestMethod.GET,
			params="!school")
	public String add5(String teacherAge){
		System.out.println("进入 !school 中深软通方法....");
		System.out.println(teacherAge);
		return "teacher/list";
	}*/
	
	
	
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/add?school=itjob
	/*@RequestMapping(value="/add",
			method=RequestMethod.GET,
			params="school!=szrt")
	public String add6(String teacherAge){
		System.out.println("进入 school!=szrt 中深软通方法....");
		System.out.println(teacherAge);
		return "teacher/list";
	}*/
	
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/fina
	@RequestMapping(value="/fin*")
	public String find(){
		System.out.println("进入find方法....");
		return "teacher/list";
	}
	
	
	
	//重点掌握
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/get/33/huanglaoshi
	//http://localhost:8080/mvn-springmvc-01-1609/teacher/get/age/laoshi
	@RequestMapping(value="/get/{age}/{laoshi}")
	public String get(@PathVariable("age")    int zxx,
					  @PathVariable("laoshi") String laoshi){
		
		System.out.println("进入get方法....");
		
		System.out.println(zxx + " : " +laoshi);
		return "teacher/list";
	}
	
	
	

}
